class Solution(object):
    def maximumTime(self, time):
        t = ''
        for i in range(5):
            if time[i] == '?':
                if i == 0:
                    if time[i + 1] == '?':
                        t += '2'
                    else:
                        if time[i + 1] <= '3':
                            t += '2'
                        else:
                            t += '1'
                if i == 1:
                    if time[i - 1] == '?':
                        t += '3'
                    else:
                        if time[i - 1] == '2':
                            t += '3'
                        else:
                            t += '9'
                if i == 3:
                    t += '5'
                if i == 4:
                    t += '9'
            else:
                t += time[i]
        return t

